package com.woniuxy.commons.utils;

import javax.xml.crypto.Data;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @Author weizihan
 * @Date 2020/7/23 2020/7/23
 * @Description 时间转换工具类
 * @Since version-1.0
 */
public class TimeUtil {
    //yy-MM-dd HH:mm:ss
    public static long getTimeFile(String time) throws ParseException {
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        Date date = simpleDateFormat.parse(time);
        return date.getTime();
    }

    //时间锉转字符串 yy-MM-dd HH:mm:ss
    public static String getTimeString(long TimeFile){
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        String format = simpleDateFormat.format(TimeFile);
        return format;
    }

    public static void main(String[] args) throws ParseException {

        System.out.println(getTimeString(new Date().getTime()).split("-")[0]);
    }
}
